#include "BBEventPoolManager.h"
#include "BBEvent.h"


BBEventPoolManager::BBEventPoolManager( void )
{

}

BBEventPoolManager::~BBEventPoolManager( void )
{
	m_pEventList.clear();
}

void BBEventPoolManager::addEventListener( BBEvent* evt )
{
	if(evt == NULL)
		return;
	m_pEventList.push_back(evt);
}

void BBEventPoolManager::removeEventLIstener( BBEvent* evt )
{
	if(evt == NULL)
		return;
	std::vector<BBEvent*>::iterator itor = m_pEventList.begin();
	for(;itor!=m_pEventList.end();itor++)
	{
		if((*itor) == evt)
		{
			m_pEventList.erase(itor);
		}
	}
}

void BBEventPoolManager::clear()
{
	if(m_pEventList.empty())
		return;
	std::vector<BBEvent*>::iterator itor = m_pEventList.begin();
	for(;itor!=m_pEventList.end();itor++)
	{
		m_pEventList.erase(itor);
	}
}

void BBEventPoolManager::purgeEventPoolManager()
{
	BB_SAFE_DELETE(_mInstance);
}
